package com.edu.exam.entity.examination.online.technical;

import com.edu.exam.enums.examination.online.technical.PluginType;
import com.edu.exam.enums.examination.online.technical.PluginStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * 设备插件实体类
 *
 * 根据E-04-01设备适配子模块设计实现
 * 存储设备插件的基本信息和配置数据。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class DevicePlugin {

    /**
     * 插件ID，主键
     */
    @Id
    @Column(name = "plugin_id", length = 64)
    private String pluginId;

    /**
     * 插件名称
     */
    @Column(name = "plugin_name", length = 128, nullable = false)
    private String pluginName;

    /**
     * 插件版本
     */
    @Column(name = "plugin_version", length = 32, nullable = false)
    private String pluginVersion;

    /**
     * 插件类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "plugin_type", length = 32, nullable = false)
    private PluginType pluginType;

    /**
     * 支持的品牌
     */
    @Column(name = "supported_brands", length = 256)
    private String supportedBrands;

    /**
     * 支持的型号
     */
    @Column(name = "supported_models", columnDefinition = "TEXT")
    private String supportedModels;

    /**
     * 插件状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "plugin_status", length = 32, nullable = false)
    private PluginStatus pluginStatus;

    /**
     * 插件描述
     */
    @Column(name = "plugin_description", length = 1024)
    private String pluginDescription;

    /**
     * 插件提供商
     */
    @Column(name = "plugin_vendor", length = 128)
    private String pluginVendor;

    /**
     * 插件路径
     */
    @Column(name = "plugin_path", length = 512)
    private String pluginPath;

    /**
     * 主类名
     */
    @Column(name = "main_class", length = 256)
    private String mainClass;

    /**
     * 插件配置
     */
    @Column(name = "plugin_config", columnDefinition = "TEXT")
    private String pluginConfig;

    /**
     * 依赖信息
     */
    @Column(name = "dependencies", columnDefinition = "TEXT")
    private String dependencies;

    /**
     * 插件元数据
     */
    @Column(name = "plugin_metadata", columnDefinition = "TEXT")
    private String pluginMetadata;

    /**
     * 插件优先级
     */
    @Column(name = "plugin_priority")
    private Integer pluginPriority;

    /**
     * 是否启用
     */
    @Column(name = "is_enabled", nullable = false)
    private Boolean isEnabled;

    /**
     * 是否为核心插件
     */
    @Column(name = "is_core", nullable = false)
    private Boolean isCore;

    /**
     * 安装时间
     */
    @Column(name = "installed_time")
    private LocalDateTime installedTime;

    /**
     * 最后加载时间
     */
    @Column(name = "last_loaded_time")
    private LocalDateTime lastLoadedTime;

    /**
     * 最后更新时间
     */
    @Column(name = "last_updated_time")
    private LocalDateTime lastUpdatedTime;

    /**
     * 插件大小（字节）
     */
    @Column(name = "plugin_size")
    private Long pluginSize;

    /**
     * 使用次数
     */
    @Column(name = "usage_count")
    private Long usageCount;

    /**
     * 错误次数
     */
    @Column(name = "error_count")
    private Integer errorCount;

    /**
     * 许可证信息
     */
    @Column(name = "license_info", length = 512)
    private String licenseInfo;

    /**
     * 创建人ID
     */
    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

}